package top.datacluster.basic.algorithm.leetcode.tree;

import top.datacluster.basic.algorithm.leetcode.TreeNode;

public class LeetCode98 {

    public boolean isValidBST(TreeNode root) {
        return false;

    }

    public boolean judgeChild(TreeNode root, int parentVal){
        if (root == null){
            return true;
        }
        if ((root.left != null && root.left.val < root.val) && (root.right != null &&root.right.val > root.val)){
            if (isValidBST(root.left)){
                return isValidBST(root.right);
            }else{
                return false;
            }
        }else if (root.left == null && root.right != null && root.right.val > root.val){
            return isValidBST(root.right);
        }else if (root.right == null && root.left != null && root.left.val < root.val){
            return isValidBST(root.left);
        }else{
            return false;
        }
    }

}
